﻿<UserControl x:Class="Shammateh.Win.UI.Views.AudienceView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:xoqalControls="clr-namespace:Xoqal.Presentation.Controls;assembly=Xoqal.Presentation"
             xmlns:xoqalConverter="clr-namespace:Xoqal.Presentation.Converters;assembly=Xoqal.Presentation"
             xmlns:xoqalExtensions="clr-namespace:Xoqal.Presentation.Extentions;assembly=Xoqal.Presentation"
             xmlns:operationView="clr-namespace:Shammateh.Win.UI.Views.Operation" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <xoqalConverter:BooleanNotConverter x:Key="booleanNotConverter"/>
        <xoqalConverter:GlobalDateConverter x:Key="globalDateConverter"/>
        <xoqalConverter:GlobalDateTimeConverter x:Key="globalDateTimeConverter"/>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <DockPanel IsEnabled="{Binding IsInEditMode, Converter={StaticResource booleanNotConverter}}">
            <Grid DockPanel.Dock="Top">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>

                <TextBlock Margin="2">نام:</TextBlock>
                <TextBox Grid.Column="1" Margin="2" Text="{xoqalExtensions:DelayBinding FilterFirstName}"/>

                <TextBlock Margin="2" Grid.Column="2">نام خانوادگی:</TextBlock>
                <TextBox Margin="2" Grid.Column="3" Text="{xoqalExtensions:DelayBinding FilterLastName}"/>

            </Grid>

            <Grid  DockPanel.Dock="Bottom" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>

                <StackPanel  Orientation="Horizontal" Margin="4">
                    <Button Command="{Binding AddCommand}" Style="{StaticResource addButton}"/>
                    <Button Command="{Binding EditCommand}" Style="{StaticResource editButton}"/>
                    <Button Command="{Binding DeleteCommand}" Style="{StaticResource deleteButton}"/>
                </StackPanel>

                <xoqalControls:Pager Grid.Column="1" PagerController="{Binding Pager}" HorizontalAlignment="Right"/>
            </Grid>

            <xoqalControls:SimpleDataGrid ItemsSource="{Binding Data}" 
                      SelectedDataItem="{Binding CurrentItem}" 
                      SelectedItems="{Binding SelectedItems}"
                      Style="{StaticResource formSimpleDataGrid}"
                      PagerController="{Binding Pager}">
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding FirstName}" Header="نام" Width="Auto" />
                    <DataGridTextColumn Binding="{Binding LastName}" Header="نام خانوادگی" Width="Auto" />
                    <DataGridTextColumn Binding="{Binding Email}" Header="پست الکترونیکی" Width="Auto"/>
                    <DataGridTextColumn Binding="{Binding Comment}" Header="توضیح" Width="Auto" />
                    <DataGridTextColumn Binding="{Binding CreateTime, Converter={StaticResource globalDateTimeConverter}}" Header="زمان درج" Width="Auto" />
                    <DataGridTextColumn Binding="{Binding LastUpdateTime, Converter={StaticResource globalDateTimeConverter}}" Header="زمان آخرین ویرایش" Width="Auto" />
                </DataGrid.Columns>
            </xoqalControls:SimpleDataGrid>
        </DockPanel>

        <Expander Grid.Row="1" Style="{StaticResource operationExpander}"
              IsExpanded="{Binding IsOperationPanelExpanded}" IsEnabled="{Binding HasCurrentItem}">
            <operationView:AudienceOperationView/>
        </Expander>

    </Grid>
</UserControl>
